package cn.wolfcode.wolf2w.business.service.impl;

import cn.wolfcode.wolf2w.api.RemoteStrategyService;
import cn.wolfcode.wolf2w.api.domain.Strategy;
import cn.wolfcode.wolf2w.api.domain.StrategySearch;
import cn.wolfcode.wolf2w.business.repository.StrategyRepository;
import cn.wolfcode.wolf2w.business.service.IStrategySearchService;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * @author 浪兎兎
 * @since 2025-06-12 15:18
 */
@Service
public class StrategySearchServiceImpl implements IStrategySearchService {
    @Autowired
    private RemoteStrategyService strategyService;
    @Autowired
    private StrategyRepository strategyRepository;
    @Override
    public void initSearch() {
        List<Strategy> result = strategyService.list("inner").getData();
        result.forEach(strategy -> {
            StrategySearch strategySearch = new StrategySearch();
            BeanUtils.copyProperties(strategy, strategySearch);
            strategyRepository.save(strategySearch);
        });
    }
}
